//
//  BleSearchViewController.m
//  bgms_d
//
//  Created by Mountain on 22/1/2019.
//  Copyright © 2019 lachesis-zhu. All rights reserved.
//

#import "BleSearchViewController.h"

@interface BleSearchViewController () <BLETransDeviceSingletonDelegate>
{
    BLETransDeviceSingleton *ble;
}
@end

@implementation BleSearchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.linkBtn.layer.borderColor = kAppDeepLineColor.CGColor;
    self.linkBtn.layer.cornerRadius = 5;
    self.linkBtn.layer.masksToBounds = YES;
    self.linkBtn.layer.borderWidth = 1;
    ble = [BLETransDeviceSingleton sharedInstance];
    ble.delegate = self;
}

- (IBAction)unlink:(id)sender {
    [ble disConnect:ble._Peripheral];
}

- (void)BLETransDeviceSingletonDisConnected:(BOOL)connected
{
    [self.navigationController popViewControllerAnimated:YES];
    [ble connect:self.connectCb];
}

- (void)BLETransDeviceSingletonConnected:(BOOL)connected
{
    if (connected) {
        if (self.delegate && [self.delegate respondsToSelector:@selector(searchViewController:backData:)]) {
            [self.delegate searchViewController:self backData:@"success"];
        }
        [self.navigationController popViewControllerAnimated:YES];
    } else {
        self.connectView.hidden = NO;
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
